#ifndef CONTROLS_H
#define CONTROLS_H

#include <QVector3D>
#include <QtOpenGL>
#include <QElapsedTimer>

class Controls : public QObject
{
    Q_OBJECT

public:
    Controls (QVector3D Pos, float hAngle, float vAngle, float FoV, float Spd, float MouseSpd);

    QMatrix4x4 getViewMatrix();
    QMatrix4x4 getProjectionMatrix();

    QMatrix4x4 ViewMatrix;
    QMatrix4x4 ProjectionMatrix;
    QVector3D CPosition;
    QVector3D CDirection;
    QVector3D CRight;
    QVector3D CUp;
    float HorizontalAngle;
    float VerticalAngle;
    float InitialFoV;
    float FoV;
    float AspectRatio;
    float ZeroParallax;
    float EyeDistance;
    float Speed;
    float MouseSpeed;
    QPoint MousePos;

    bool DUALRENDER; // Doble render para el anaglifo?
    int RenderPass; // Esto permitira controlar que camara renderizaremos para el anaglifo
    void SwitchDualRender(bool value);
    void SetZeroParallax(float val);
    void SetEyeDistance(float val);
    void setCDirection(QVector3D dir);

    int width, height;
    QElapsedTimer LastTime;

#define PI 3.14159265359
#define LEFT -1
#define RIGHT 1
#define SINGLE 0

public slots:
    void computeMatricesFromInputs(int keypressed, QPoint pos);
    void parentResized(int w, int h);
    void computeDualRender();

signals:
    void cameraMoves (QVector3D pos);
};

#endif // CONTROLS_H
